<?php
    require_once "../../config.php";
    require_once "../../functions.php";
    //获取登录后session中存储的用户id
    session_start();
    $userId = $_SESSION["user_id"];
    //连接数据库
    $connect = connect();
    //sql语句
    $sql = "select * from users where id = {$userId}";
    //执行sql语句,获取一个二维数组
    $queryResult = querySelect($connect,$sql);
    // print_r($queryResult);
    $respones = ["code"=>0,"msg"=>"操作失败"];
    //判断是不是存在这个用户
    if($queryResult){
        $respones["code"] = 1;
        $respones["msg"] ="操作成功";
        $respones["avatar"] = $queryResult[0]["avatar"];
        $respones["nickname"] = $queryResult[0]["nickname"];
    }
    //返回json数据
    header("content-type:application/json");
    echo json_encode($respones);
?>